package com.ygq.train.batch.job;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import com.ygq.train.batch.openfeign.BusinessOpenFeign;
import com.ygq.train.common.resp.CommonResp;
import jakarta.annotation.Resource;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

public class DailyTrainJob implements Job {

    @Resource
    private BusinessOpenFeign businessOpenFeign;
    private static final Logger LOG= LoggerFactory.getLogger(DailyTrainJob.class);
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

        LOG.info("生成15天后的车次数据开始");
        Date date = new Date();
        DateTime dateTime = DateUtil.offsetDay(date, 15);
        Date offSetDay = dateTime.toJdkDate();
        CommonResp<Object> genDaily = businessOpenFeign.genDaily(offSetDay);
        LOG.info("生成15天后的车次数据结束. 结果：{}" ,genDaily);

    }
}
